﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BLToolkit.DataAccess;
using Clipping.Utils;
using System.IO;
using BLToolkit.Validation;

namespace ClippingMaster
{
    [TableName(Name = "KeywordsCategory")]
    public class KEYWORDSCATEGORY : ModelBase<KEYWORDSCATEGORY>
    {
        class KEYWORDSCATEGORYUpdater : DBPartUpdater<KEYWORDSCATEGORYUpdater>
        {
            static KEYWORDSCATEGORYUpdater()
            {
                Actions[typeof(KEYWORDSCATEGORYUpdater)] = new List<UpdateAction>();

                #region 数据库升级脚本

                Versions[typeof(KEYWORDSCATEGORYUpdater)] = 0;

                #region 创建表 Keywords

                AddUpdateAction(typeof(KEYWORDSCATEGORYUpdater), @"CREATE TABLE KeywordsCategory(
ID VARCHAR2(100) NOT NULL,
Name VARCHAR2(100) NOT NULL,
ParentID VARCHAR(10) NOT NULL
);      
");
                #endregion

                #endregion
            }
        }

        static KEYWORDSCATEGORY()
        {
            string keywordDBPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DB", "keywords.db");
            var keywordDBConnectionPool = DBHelper.CreateDBConnectionPool<KeywordDBUpdater>(keywordDBPath, 10);
            DBHelper.UpdateTableSchema<KEYWORDSCATEGORYUpdater>(keywordDBConnectionPool);
        }

        /// <summary>
        /// ID
        /// </summary>
        [PrimaryKey(0), Required]
        public string ID { get; set; }
        /// <summary>
        ///名称
        /// </summary>
        [Required]
        public string Name { get; set; }
        /// <summary>
        /// 
        /// </summary>
        [Required]
        public string ParentID { get; set; }
    }
}
